#ifndef ATTRIBUTESWIDGET_H
#define ATTRIBUTESWIDGET_H
//
#include <QTreeWidget>
//
class Attribute;
class QDomNode;

//
class AttributesModel : public QAbstractListModel
{
Q_OBJECT
	QList <Attribute*> _attributes;
	
	void updateAttributesOrder(); // update attribute order (after changing position)
public:
	AttributesModel(QObject *parent=0);
	~AttributesModel();
	int rowCount(const QModelIndex &parent) const;
	QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
	
	void addAttribute(QMap<QString,QString> params);
	bool addAttribute(QDomNode &node);	
	void removeAttributes(QModelIndexList ilist);
	void editAttribute(QModelIndex &index);
	void clear();
	void checkUsed(QTreeWidget *tree);
	bool checkUsed(QTreeWidgetItem *item,int order);
	Attribute *attrFromIndex(const QModelIndex &index);
	int newNumber();
	Attribute *attribute(int order);
	void xml(QDomNode &node);
	Qt::ItemFlags flags(const QModelIndex &index) const;
	Qt::DropActions supportedDropActions() const;
	QStringList mimeTypes() const;
	QMimeData *mimeData(const QModelIndexList &indexes) const;
	void moveAttribute(int nom,QModelIndex &index);
	QString newName(); // возвращает новое имя для координаты
	bool removeRows(int row,int count,const QModelIndex &parent=QModelIndex());
signals:
	void attrChanged(int,Attribute*);    	
};
#endif
